<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            list-style: none;
        }

        .oul {
            display: flex;
            text-align: center;
            line-height: 50px;
        }

        .oul li {
            flex: 1;
            background: #544f6b;
            color: #8478B3;
        }

        .active {
            background: #fff !important;
            color: #655c89 !important;
        }
    </style>
</head>

<body>
    <div id="app">
        <ul class="oul">
            <!-- v-bind : -->
            <!-- v-on @ -->
            <!-- <li :class="index === count? 'active': ''"
                @click="change(index)"
                v-for="(item, index) in list">
                {{ item }}
            </li> -->

            <!-- 类名绑定 -->
            <li :class="{ active: index === count }" @click="change(index)" v-for="(item, index) in list">
                {{ item }}
            </li>
        </ul>

        <div class="box">
            {{ content[count] }}
        </div>
    </div>

    <script src="./js/vue.js"></script>
    <script>
        new Vue({
            el: "#app",
            data: {
                list: ["Tab1", "Tab2", "Tab3"],
                content: [
                    "ula eleifend adipiscing. Duis aliquam molestie erat.",
                    "Ut et mauris vel pede varius solellus ipque tempus lectus.",
                    "Duis orci. Aliquam sodales tortor vitae ipsum. Aliquam nulla."],
                count: 0
            },
            // 存放函数
            methods: {
                change(index) {
                    this.count = index
                    // console.log(index)
                }
            }
        })
    </script>
</body>

</html>